//
//  Style5TableViewController.m
//  PiPiPineapple
//
//  Created by 李晓东 on 17/11/14.
//  Copyright © 2017年 PeanutXu. All rights reserved.
//

#import "Style5ViewController.h"
#import "content/ContentTableViewController.h"
#import "UIBarButtonItem+Category.h"

#import <Masonry.h>

@interface Style5ViewController () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) NSArray *array;

@property (nonatomic, strong)  UITableView *tableView;
@property (nonatomic, assign) NSInteger selectedIndex;
@end

@implementation Style5ViewController

- (void)loadView{
    [super loadView];
    _tableView = [[UITableView alloc]init];
    [self.view addSubview:_tableView];
    [_tableView setBackgroundColor:[UIColor whiteColor]];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.view.mas_top);
        make.left.mas_equalTo(self.view.mas_left);
        make.width.mas_equalTo(self.view.mas_width);
        make.height.mas_equalTo(self.view.mas_height);
    }];
    
    [_tableView setDelegate:self];
    [_tableView setDataSource:self];
    
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:Style5CellId];
    _array = [NSArray arrayWithObjects:@"第一掌", @"第二掌", @"第三掌", @"第四掌",
              @"第五掌", @"第六掌", @"第七掌", @"第八掌",
              @"第九掌", @"第十掌", @"第十一掌", @"第十二掌",
              @"第十三掌", @"第十四掌", @"第十五掌", @"第十六掌",
              @"第十七掌", @"第十八掌", nil];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"说明" style: UIBarButtonItemStylePlain target:self action:@selector(explain:) index:31];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Style5CellId];
    UIView *backgroundView = [[UIView alloc]init];
    [backgroundView setBackgroundColor:[UIColor redColor]];
    [cell setSelectedBackgroundView:backgroundView];
    cell.textLabel.text = _array[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    _selectedIndex = indexPath.row + 981;
    [self.navigationController pushViewController:[[ContentTableViewController alloc]initWithFlag:indexPath.row] animated:YES];
}
@end
